package com.szc.demo01.controller;

import com.szc.demo01.pojo.TBook;
import com.szc.demo01.pojo.User;
import com.szc.demo01.service.BookService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.MatrixVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 测试控制器
 */
@Slf4j
@Controller
public class TestController {

    @Resource
    BookService bookService;

    @Value("${Path}")
    private String a;

    @ResponseBody
    @RequestMapping("/a")
    public String a(Model model){
        return "adada";
    }


    /**
     * 矩阵变量
     * value 变量名
     * pathVar 来自哪个路径
     * required 是否必须
     */
    @ResponseBody
    @RequestMapping("/m/{test}")
    public Map<String, String> test2(@MatrixVariable(value = "value1",pathVar = "test") String value1,
                                     @MatrixVariable(value = "value2",pathVar = "test",required = false) String value2){
        Map<String ,String> hashMap = new HashMap<>();
        hashMap.put("value1",value1);
        hashMap.put("value2",value2);
        return hashMap;
    }

}
